package com.itheima.aop;


import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class MyAspect {

    @Pointcut("execution(* com.itheima.dao.Impl.BookDaoImpl.*())")
    private void pt(){}

    @Around("pt()")
    public void method(ProceedingJoinPoint joinPoint) throws Throwable {

        Long start = System.currentTimeMillis();

        for (int i = 0; i < 10000; i++) {
            joinPoint.proceed();
        }

        Long end = System.currentTimeMillis();

        String name = joinPoint.getSignature().getName();

        System.out.println(name + "方法万次执行时间为：" + (end - start) + "ms");
    }
}
